<!DOCTYPE html>
<html lang="zh-Hans">

<head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="x5-fullscreen" content="true">
<meta name="full-screen" content="yes">
<meta name="theme-color" content="#317EFB" />
<meta content="width=device-width, initial-scale=1.0, maximum-scale=5.0, user-scalable=0" name="viewport">
<meta name="description" content="s Git常用命令（Git重点）Git全局设置当安装Git后首先要做的事情是设置用户名称和email地址。这是非常重要的，因为每次Git提交都会使用该用户信息 打开Git，在Git命令行中执行下面命令：1.设置用户信息(不受限制，随意设置)     git config --global user.name &quot;你的用户名&quot;     git config --global use">
<meta property="og:type" content="article">
<meta property="og:title" content="学会使用Git">
<meta property="og:url" content="https://big-ttong/myblog.git/2023/07/19/%E5%AD%A6%E4%BC%9A%E4%BD%BF%E7%94%A8Git/index.html">
<meta property="og:site_name" content="欢迎访问我的blog">
<meta property="og:description" content="s Git常用命令（Git重点）Git全局设置当安装Git后首先要做的事情是设置用户名称和email地址。这是非常重要的，因为每次Git提交都会使用该用户信息 打开Git，在Git命令行中执行下面命令：1.设置用户信息(不受限制，随意设置)     git config --global user.name &quot;你的用户名&quot;     git config --global use">
<meta property="og:locale">
<meta property="article:published_time" content="2023-07-19T12:05:20.201Z">
<meta property="article:modified_time" content="2023-08-01T00:18:45.799Z">
<meta property="article:author" content="洪汉桐">
<meta name="twitter:card" content="summary">


<title >学会使用Git</title>

<!-- Favicon -->

    <link href='/myblog/log.svg?v=2.0.9' rel='icon' type='image/png' sizes='16x16' ></link>


    <link href='/myblog/log.svg?v=2.0.9' rel='icon' type='image/png' sizes='32x32' ></link>


    <link href='/myblog/log.svg?v=2.0.9' rel='apple-touch-icon' sizes='180x180' ></link>


    <link href='/myblog/site.webmanifest' rel='manifest' ></link>


<!-- Plugin -->




    
<link rel="stylesheet" href="/myblog/css/plugins/bootstrap.row.css">

    
<link rel="stylesheet" href="https://unpkg.com/locomotive-scroll@4.1.4/dist/locomotive-scroll.min.css">

    
<link rel="stylesheet" href="https://unpkg.com/@fancyapps/ui@4.0/dist/fancybox.css">

    
    




<!-- Icon -->

    
<link rel="stylesheet" href="/myblog/css/plugins/font-awesome.min.css">




<!-- Variable -->
<script>window.ASYNC_CONFIG = {"hostname":"big-ttong","author":"洪汉桐","root":"/myblog/","typed_text":["extraordinary"],"theme_version":"2.0.9","theme":{"switch":true,"default":"style-light"},"favicon":{"logo":"log.svg","icon16":"log.svg","icon32":"log.svg","appleTouchIcon":"log.svg","webmanifest":"/site.webmanifest","visibilitychange":true,"hidden":"failure.ico","showText":"(/≧▽≦/)咦！又好了！","hideText":"(●—●)喔哟，崩溃啦！"},"i18n":{"placeholder":"搜索文章...","empty":"找不到您查询的内容: ${query}","hits":"找到 ${hits} 条结果","hits_time":"找到 ${hits} 条结果（用时 ${time} 毫秒）","author":"本文作者：","copyright_link":"本文链接：","copyright_license_title":"版权声明：","copyright_license_content":"本博客所有文章除特别声明外，均默认采用 undefined 许可协议。","copy_success":"复制成功","copy_failure":"复制失败","open_read_mode":"进入阅读模式","exit_read_mode":"退出阅读模式","notice_outdate_message":"距离上次更新已经 undefined 天了, 文章内容可能已经过时。","just":"刚刚","min":"分钟前","hour":"小时前","day":"天前","month":"个月前"},"swup":false,"plugin":{"flickr_justified_gallery":"https://unpkg.com/flickr-justified-gallery@latest/dist/fjGallery.min.js"},"icons":{"sun":"far fa-sun","moon":"far fa-moon","play":"fas fa-play","email":"far fa-envelope","next":"fas fa-arrow-right","calendar":"far fa-calendar-alt","clock":"far fa-clock","user":"far fa-user","back_top":"fas fa-arrow-up","close":"fas fa-times","search":"fas fa-search","reward":"fas fa-hand-holding-usd","user_tag":"fas fa-user-alt","toc_tag":"fas fa-th-list","read":"fas fa-book-reader","arrows":"fas fa-arrows-alt-h","double_arrows":"fas fa-angle-double-down","copy":"fas fa-copy"},"icontype":"font","highlight":{"plugin":"highlighjs","theme":true,"copy":true,"lang":true,"title":"default","height_limit":200},"notice_outdate":{"enable":true,"style":"flat","limit_day":365,"position":"top"}};</script>
<script id="async-page-config">window.PAGE_CONFIG = {"isPost":true,"isHome":false,"postUpdate":"2023-08-01 08:18:45"};</script>

<!-- Theme mode css -->
<link data-swup-theme rel="stylesheet" href="/myblog/css/index.css?v=2.0.9" id="trm-switch-style">
<script>
    let defaultMode = ASYNC_CONFIG.theme.default !=='auto' ?  ASYNC_CONFIG.theme.default : (window.matchMedia("(prefers-color-scheme: light)").matches ? 'style-light' : 'style-dark')
    let catchMode = localStorage.getItem('theme-mode') || defaultMode;
    let type = catchMode === 'style-dark' ? 'add' : 'remove';
    document.documentElement.classList[type]('dark')
</script>

<!-- CDN -->


    
    



<!-- Site Analytics -->
 
<meta name="generator" content="Hexo 6.3.0"></head>

<body>

  <!-- app wrapper -->
  <div class="trm-app-frame">

    <!-- page preloader -->
    <div class="trm-preloader">
    <div class="trm-holder">
        <div class="preloader">
            <div></div>
            <div></div>
            <div></div>
            <div></div>
            <div></div>
            <div></div>
            <div></div>
            <div></div>
            <div></div>
            <div></div>
        </div>
    </div>
</div>
    <!-- page preloader end -->

    <!-- change mode preloader -->
    <div class="trm-mode-swich-animation-frame">
    <div class="trm-mode-swich-animation">
        <i class="i-sun"><i class="iconfont far fa-sun"></i></i>
        <div class="trm-horizon"></div>
        <i class="i-moon"><i class="iconfont far fa-moon"></i></i>
    </div>
</div>
    <!-- change mode preloader end -->

      <!-- scroll container -->
      <div id="trm-dynamic-content" class="trm-swup-animation">
        <div id="trm-scroll-container" class="trm-scroll-container" data-scroll-container style="opacity: 0">
          <div data-scroll-section id="content" class="trm-scroll-section">

            <div class="locomotive-scroll__sticky-target" style="position: absolute; top: 0; left: 0; right: 0; bottom: 0; pointer-events: none;"></div>

            <!-- top bar -->
            <header class="trm-top-bar" data-scroll data-scroll-sticky data-scroll-target=".locomotive-scroll__sticky-target" data-scroll-offset="-10">
	<div class="container">
		<div class="trm-left-side">
			<!-- logo -->
<a href="/myblog/" class="trm-logo-frame trm-anima-link">
    
        <img alt="logo" src="/myblog/log.svg">
    
    
        <div class="trm-logo-text">
            洪<span>汉桐</span>
        </div>
    
</a>
<!-- logo end -->
		</div>
		<div class="trm-right-side">
			<!-- menu -->
<div class="trm-menu">
    <nav>
        <ul>
            
            <li class="menu-item-has-children ">
                <a  href="/myblog/" target="">
                    首页
                </a>
                
            </li>
            
            <li class="menu-item-has-children ">
                <a  href="/myblog/archives/" target="">
                    归档
                </a>
                
            </li>
            
        </ul>
    </nav>
</div>
<!-- menu end -->
			
    <!-- mode switcher place -->
    <div class="trm-mode-switcher-place">
        <div class="trm-mode-switcher">
            <i class="iconfont far fa-sun"></i>
            <input class="tgl tgl-light" id="trm-swich" type="checkbox">
            <label class="trm-swich" for="trm-swich"></label>
            <i class="iconfont far fa-moon"></i>
        </div>
    </div>
    <!-- mode switcher place end -->

			
		</div>
		<div class="trm-menu-btn">
			<span></span>
		</div>
	</div>
</header>
            <!-- top bar end -->

            <!-- body -->
            
<div class="trm-content-start">
    <!-- banner -->
    <div class="trm-banner" data-scroll data-scroll-direction="vertical">
    
    <!-- banner cover -->
    <img style="object-position:top;object-fit:cover;" alt="banner" class="trm-banner-cover" data-scroll data-scroll-direction="vertical" data-scroll-speed="-3" src="/myblog/img/banner.png">
    <!-- banner cover end -->
    

    <!-- banner content -->
    <div class="trm-banner-content trm-overlay">
        <div class="container" data-scroll data-scroll-direction="vertical" data-scroll-speed="0">
            <div class="row">
                
                <div class="col-lg-4"></div>
                
                <div class="col-lg-8">

                    <!-- banner title -->
                    <div class="trm-banner-text ">
                        <div class="trm-label trm-mb-20">
                            NEWS LETTER
                        </div>
                        <h1 class="trm-mb-30 trm-hsmb-font">
                            学会使用Git
                        </h1>

                        
                            <ul class="trm-breadcrumbs trm-label">
                                <li>
                                    <a href="/myblog/" class="trm-anima-link">Home</a>
                                </li>
                                <li>
                                    <span>
                                        2023
                                    </span
                                ></li>
                            </ul>
                        
                    </div>
                    <!-- banner title end -->

                    <!-- scroll hint -->
                    <a href="#about-triger" data-scroll-to="#about-triger" data-scroll-offset="-130" class="trm-scroll-hint-frame">
                        <div class="trm-scroll-hint"></div>
                        <span class="trm-label">Scroll down</span>
                    </a>
                    <!-- scroll hint end -->

                </div>
            </div>
        </div>
    </div>
    <!-- banner content end -->
</div>
    <!-- banner end -->
    <div class="container">
        <div class="row">
            
                <div id="page-sidebar" class="col-lg-4 hidden-sm">
                    <!-- main card -->
                    

<div class="trm-main-card-frame trm-sidebar">
    <div class="trm-main-card" data-scroll data-scroll-repeat data-scroll-sticky data-scroll-target=".locomotive-scroll__sticky-target" data-scroll-offset="60"> 
    
        <div class="trm-user-tabs" id="sidebar-tabs">
           <div class="trm-tabs-nav trm-mb-40" id="trm-tabs-nav">
                <div data-to="tabs-user" class="trm-tabs-nav-item">
                    <i class="iconfont fas fa-user-alt"></i>
                </div>
                <div data-to="tabs-toc" class="trm-tabs-nav-item active">
                    <i class="iconfont fas fa-th-list"></i>
                </div>
           </div>
            <div name="tabs-user" class="trm-tabs-item">
                <!-- card header -->
<div class="trm-mc-header">
    <div class="trm-avatar-frame trm-mb-20">
        <img alt="Avatar" class="trm-avatar trm-light-icon" src="/myblog/img/profilephoto2.jpg"> <img alt="Avatar" class="trm-avatar trm-dark-icon" src="/myblog/img/profilephoto1.jpg">
    </div>
    <h5 class="trm-name trm-mb-15">
        洪汉桐
    </h5>
    
        <div class="trm-label">
            I`m
            <span class="trm-typed-text">
                <!-- Words for theme.user.typedText -->
            </span>
        </div>
    
</div>
<!-- card header end -->
                <!-- sidebar social -->

<div class="trm-divider trm-mb-40 trm-mt-40"></div>
<div class="trm-social">
    
        <a href="https://github.com" title="Github" rel="nofollow" target="_blank">
            <i class="iconfont fab fa-github"></i>
        </a>
    
</div>

<!-- sidebar social end -->
                <!-- info -->
<div class="trm-divider trm-mb-40 trm-mt-40"></div>
<ul class="trm-table trm-mb-20">
    
        <li>
            <div class="trm-label">
                地址:
            </div>
            <div class="trm-label trm-label-light">
                河北雄安
            </div>
        </li>
    
        <li>
            <div class="trm-label">
                年龄:
            </div>
            <div class="trm-label trm-label-light">
                19
            </div>
        </li>
    
</ul>
<!-- info end -->

                
    <div class="trm-divider trm-mb-40 trm-mt-40"></div>
    <!-- action button -->
    <div class="text-center">
        <a href="mailto:2067046599@qq.com" class="trm-btn">
            联系我
            <i class="iconfont far fa-envelope"></i>
        </a>
    </div>
    <!-- action button end -->

            </div>
            <div name="tabs-toc" class="trm-tabs-item active">
                <div class="post-toc">
    <ol class="toc"><li class="toc-item toc-level-1"><a rel="nofollow" class="toc-link" href="#Git常用命令（Git重点）"  data-scroll-to="#Git常用命令（Git重点）"><span class="toc-number">1.</span> <span class="toc-text">Git常用命令（Git重点）</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a rel="nofollow" class="toc-link" href="#Git全局设置"  data-scroll-to="#Git全局设置"><span class="toc-number">1.1.</span> <span class="toc-text">Git全局设置</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a rel="nofollow" class="toc-link" href="#打开Git，在Git命令行中执行下面命令："  data-scroll-to="#打开Git，在Git命令行中执行下面命令："><span class="toc-number">1.1.1.</span> <span class="toc-text">打开Git，在Git命令行中执行下面命令：</span></a></li></ol></li><li class="toc-item toc-level-2"><a rel="nofollow" class="toc-link" href="#获取Git仓库"  data-scroll-to="#获取Git仓库"><span class="toc-number">1.2.</span> <span class="toc-text">获取Git仓库</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a rel="nofollow" class="toc-link" href="#两种方式"  data-scroll-to="#两种方式"><span class="toc-number">1.2.1.</span> <span class="toc-text">两种方式</span></a></li></ol></li><li class="toc-item toc-level-2"><a rel="nofollow" class="toc-link" href="#工作区，暂存区，版本库-概念"  data-scroll-to="#工作区，暂存区，版本库-概念"><span class="toc-number">1.3.</span> <span class="toc-text">工作区，暂存区，版本库 概念</span></a></li><li class="toc-item toc-level-2"><a rel="nofollow" class="toc-link" href="#Git工作区中文件的状态"  data-scroll-to="#Git工作区中文件的状态"><span class="toc-number">1.4.</span> <span class="toc-text">Git工作区中文件的状态</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a rel="nofollow" class="toc-link" href="#两种状态"  data-scroll-to="#两种状态"><span class="toc-number">1.4.1.</span> <span class="toc-text">两种状态</span></a></li></ol></li><li class="toc-item toc-level-2"><a rel="nofollow" class="toc-link" href="#本地仓库操作"  data-scroll-to="#本地仓库操作"><span class="toc-number">1.5.</span> <span class="toc-text">本地仓库操作</span></a></li><li class="toc-item toc-level-2"><a rel="nofollow" class="toc-link" href="#远程仓库操作"  data-scroll-to="#远程仓库操作"><span class="toc-number">1.6.</span> <span class="toc-text">远程仓库操作</span></a></li><li class="toc-item toc-level-2"><a rel="nofollow" class="toc-link" href="#分支操作"  data-scroll-to="#分支操作"><span class="toc-number">1.7.</span> <span class="toc-text">分支操作</span></a></li><li class="toc-item toc-level-2"><a rel="nofollow" class="toc-link" href="#标签操作"  data-scroll-to="#标签操作"><span class="toc-number">1.8.</span> <span class="toc-text">标签操作</span></a></li></ol></li><li class="toc-item toc-level-1"><a rel="nofollow" class="toc-link" href="#在IDEA中使用Git"  data-scroll-to="#在IDEA中使用Git"><span class="toc-number">2.</span> <span class="toc-text">在IDEA中使用Git</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a rel="nofollow" class="toc-link" href="#在IDEA中配置Git"  data-scroll-to="#在IDEA中配置Git"><span class="toc-number">2.1.</span> <span class="toc-text">在IDEA中配置Git</span></a></li><li class="toc-item toc-level-2"><a rel="nofollow" class="toc-link" href="#获取Git仓库-1"  data-scroll-to="#获取Git仓库-1"><span class="toc-number">2.2.</span> <span class="toc-text">获取Git仓库</span></a></li><li class="toc-item toc-level-2"><a rel="nofollow" class="toc-link" href="#本地仓库操作-1"  data-scroll-to="#本地仓库操作-1"><span class="toc-number">2.3.</span> <span class="toc-text">本地仓库操作</span></a></li><li class="toc-item toc-level-2"><a rel="nofollow" class="toc-link" href="#远程仓库操作-1"  data-scroll-to="#远程仓库操作-1"><span class="toc-number">2.4.</span> <span class="toc-text">远程仓库操作</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a rel="nofollow" class="toc-link" href="#查看远程仓库"  data-scroll-to="#查看远程仓库"><span class="toc-number">2.4.1.</span> <span class="toc-text">查看远程仓库</span></a></li><li class="toc-item toc-level-3"><a rel="nofollow" class="toc-link" href="#添加远程仓库"  data-scroll-to="#添加远程仓库"><span class="toc-number">2.4.2.</span> <span class="toc-text">添加远程仓库</span></a></li><li class="toc-item toc-level-3"><a rel="nofollow" class="toc-link" href="#推送远程仓库"  data-scroll-to="#推送远程仓库"><span class="toc-number">2.4.3.</span> <span class="toc-text">推送远程仓库</span></a></li><li class="toc-item toc-level-3"><a rel="nofollow" class="toc-link" href="#从远程仓库拉取"  data-scroll-to="#从远程仓库拉取"><span class="toc-number">2.4.4.</span> <span class="toc-text">从远程仓库拉取</span></a></li></ol></li><li class="toc-item toc-level-2"><a rel="nofollow" class="toc-link" href="#分支操作-1"  data-scroll-to="#分支操作-1"><span class="toc-number">2.5.</span> <span class="toc-text">分支操作</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a rel="nofollow" class="toc-link" href="#查看分支"  data-scroll-to="#查看分支"><span class="toc-number">2.5.1.</span> <span class="toc-text">查看分支</span></a></li><li class="toc-item toc-level-3"><a rel="nofollow" class="toc-link" href="#创建分支"  data-scroll-to="#创建分支"><span class="toc-number">2.5.2.</span> <span class="toc-text">创建分支</span></a></li><li class="toc-item toc-level-3"><a rel="nofollow" class="toc-link" href="#切换分支"  data-scroll-to="#切换分支"><span class="toc-number">2.5.3.</span> <span class="toc-text">切换分支</span></a></li><li class="toc-item toc-level-3"><a rel="nofollow" class="toc-link" href="#将分支推送到远程仓库"  data-scroll-to="#将分支推送到远程仓库"><span class="toc-number">2.5.4.</span> <span class="toc-text">将分支推送到远程仓库</span></a></li><li class="toc-item toc-level-3"><a rel="nofollow" class="toc-link" href="#合并分支"  data-scroll-to="#合并分支"><span class="toc-number">2.5.5.</span> <span class="toc-text">合并分支</span></a></li></ol></li></ol></li></ol>
</div>
            </div>
        </div>
    
    </div>
</div>
                    <!-- main card end -->
                </div>
            
            <div id="page-content" class="col-lg-8">
                <div class="trm-content" id="trm-content">
                    <div data-scroll data-scroll-repeat data-scroll-offset="500" id="about-triger"></div>

                    <div id="post-info" class="row hidden-sm">
    <div class="col-sm-4">
        <div class="trm-card trm-label trm-label-light text-center">
            <i class="iconfont far fa-calendar-alt trm-icon"></i><br>
            07/19
        </div>
    </div>
    <div class="col-sm-4">
        <div class="trm-card trm-label trm-label-light text-center">
            <i class="iconfont far fa-clock trm-icon"></i><br>
            20:05
        </div>
    </div>
    <div class="col-sm-4">
        <div id="post-author" class="trm-card trm-label trm-label-light text-center">
            <i class="iconfont far fa-user trm-icon"></i><br>
            洪汉桐
        </div>
    </div>
</div>
<div class="trm-card ">
    <article id="article-container" class="trm-publication">
    <p>s</p>
<h1 id="Git常用命令（Git重点）"><a href="#Git常用命令（Git重点）" class="headerlink" title="Git常用命令（Git重点）"></a>Git常用命令（Git重点）</h1><h2 id="Git全局设置"><a href="#Git全局设置" class="headerlink" title="Git全局设置"></a>Git全局设置</h2><p><strong>当安装Git后首先要做的事情是设置用户名称和email地址。这是非常重要的，因为每次Git提交都会使用该用户信息</strong></p>
<h3 id="打开Git，在Git命令行中执行下面命令："><a href="#打开Git，在Git命令行中执行下面命令：" class="headerlink" title="打开Git，在Git命令行中执行下面命令："></a>打开Git，在Git命令行中执行下面命令：</h3><pre><code>1.设置用户信息(不受限制，随意设置)
    git config --global user.name &quot;你的用户名&quot;
    git config --global user.email &quot;你的邮箱&quot;
2.查看配置信息
    git config --list
</code></pre>
<h2 id="获取Git仓库"><a href="#获取Git仓库" class="headerlink" title="获取Git仓库"></a>获取Git仓库</h2><h3 id="两种方式"><a href="#两种方式" class="headerlink" title="两种方式"></a>两种方式</h3><pre><code>一.在本地初始化一个Git仓库（不常用）
    执行步骤如下：
        1.在任意目录下创建一个空目录作为我们的本地Git仓库
        2.进入这个目录，点击右键打开Git bash窗口
        3.执行命令git init    （执行之后会出现一个master分支，我们后边学习）
    如果在当前目录中看到.git文件夹（此文件夹为隐藏文件夹）说明Git仓库创建成功
二.从远程仓库克隆（常用）
    登录gitee，复制我们远程仓库的地址
    在目录同级右键打开 Git bash窗口
    执行命令 git clone 远程仓库的地址
</code></pre>
<h2 id="工作区，暂存区，版本库-概念"><a href="#工作区，暂存区，版本库-概念" class="headerlink" title="工作区，暂存区，版本库 概念"></a>工作区，暂存区，版本库 概念</h2><p>工作区：包含.git文件夹的目录就是工作区，也成为工作目录，主要用于存放开发的代码<br>暂存区：.git文件夹中有很多文件，其中有一个index文件就是暂存区，也可以叫做stage。暂存区是一个临时保存修改文件的地方<br>版本库：前面看到的.git隐藏文件夹就是版本库，版本库中存储了很多配置信息，日志信息和文件版本信息等</p>
<p>工作区 使用命令 git add . 就会将内容放到暂存区 在使用命令 git commit 则会将内容推送到版本库</p>
<h2 id="Git工作区中文件的状态"><a href="#Git工作区中文件的状态" class="headerlink" title="Git工作区中文件的状态"></a>Git工作区中文件的状态</h2><h3 id="两种状态"><a href="#两种状态" class="headerlink" title="两种状态"></a>两种状态</h3><pre><code>一.untracked 未跟踪（未被纳入版本控制）
二.tracked 已跟踪（被纳入版本控制）
    1.Unmodified 未修改状态
    2.Modified 已修改状态
    3.Staged 已暂存状态

注意：这些文件的状态会随着我们执行Git的命令发生变化
</code></pre>
<h2 id="本地仓库操作"><a href="#本地仓库操作" class="headerlink" title="本地仓库操作"></a>本地仓库操作</h2><p>git status  —查看文件状态<br>git add     —将文件的修改加入暂存区<br>git reset   —将暂存区的文件取消暂存或者切换到指定版本（git reset –hard 想要的版本参数）<br>git commit  —将暂存区的文件修改提交到版本库<br>git log     —查看日志</p>
<h2 id="远程仓库操作"><a href="#远程仓库操作" class="headerlink" title="远程仓库操作"></a>远程仓库操作</h2><p>git remote  —查看远程仓库<br>git remote add   —添加远程仓库<br>git clone   —从远程仓库克隆<br>git pull    —从远仓库拉取<br>git push    —推送到远程仓库</p>
<h2 id="分支操作"><a href="#分支操作" class="headerlink" title="分支操作"></a>分支操作</h2><p>分支是Git使用过程中非常重要的概念。使用分支意味着你可以把你的工作从开发主线上分离开来，以免影响开发主线。同一个仓库可以有多个分支，各个分支相互独立，互不干扰。<br>通过git init 命令创建本地仓库时默认会创建一个master分支</p>
<p>相关命令：<br>git branch   —查看分支<br>    git branch -r —列出所有远程分支<br>    git branch -a —列出所有本地分支和远程分支<br>git branch【name】   —创建分支<br>git checkout 【name】   —切换分支<br>git push 【shortName】【name】 —推送至远程仓库分支<br>git merge 【name】   —合并分支</p>
<h2 id="标签操作"><a href="#标签操作" class="headerlink" title="标签操作"></a>标签操作</h2><p>Git中的标签，指的是某个分支某个特定时间点的状态。通过标签，可以很方便的切换到标记时的状态。（经常来记录发布结点（v1.0、v1.2等））<br>git tag   —列出已有的标签<br>git tag【name】   —创建标签<br>git push【shortName】【name】   —将标签推送至远程仓库<br>git checkout -b【branch】【name】   —检出标签</p>
<h1 id="在IDEA中使用Git"><a href="#在IDEA中使用Git" class="headerlink" title="在IDEA中使用Git"></a>在IDEA中使用Git</h1><h2 id="在IDEA中配置Git"><a href="#在IDEA中配置Git" class="headerlink" title="在IDEA中配置Git"></a>在IDEA中配置Git</h2><p>打开IDEA 》》 File 》》Settings 》》Version Control 》》Git 》》Path to Git executable 选择git.exe的安装路径。<br>点击Test，如果出现版本号，就配置成功了，还是非常简单的</p>
<h2 id="获取Git仓库-1"><a href="#获取Git仓库-1" class="headerlink" title="获取Git仓库"></a>获取Git仓库</h2><p>新建一个Maven项目（最简单的即可），点击 VCS 》》 import into Version Control 》》 Create Git Repository 选中我们的项目，项目就变成了git仓库目录 等价于 （git init）<br>此时会出现Git图标<br>在IDEA获取仓库两种方式：<br>1.本地仓库初始</p>
<p>2.远程仓库克隆<br>    1.VCS 》》 Get from Version Control..  或者  关闭项目，在IDEA初始页面点击Get…<br>    2.将gitee或者github的仓库路径复制 》》 放入URL  然后放入项目，最好再加一个目录层 和仓库名相同<br>一些文件的作用：<br>.gitignore  —配置哪些文件不需要git管理</p>
<h2 id="本地仓库操作-1"><a href="#本地仓库操作-1" class="headerlink" title="本地仓库操作"></a>本地仓库操作</h2><pre><code>将文件加入暂存区
 创建一个controller，会有弹窗显示，是否加入git管理
 
将暂存区的文件提交到版本库
    右键想要提交的文件 》 Git 》commit 选择
查看日志
    点击IDEA下方Log
</code></pre>
<h2 id="远程仓库操作-1"><a href="#远程仓库操作-1" class="headerlink" title="远程仓库操作"></a>远程仓库操作</h2><h3 id="查看远程仓库"><a href="#查看远程仓库" class="headerlink" title="查看远程仓库"></a>查看远程仓库</h3><pre><code>右键项目 》》 Git 》》Repository 》》Remotes.
</code></pre>
<h3 id="添加远程仓库"><a href="#添加远程仓库" class="headerlink" title="添加远程仓库"></a>添加远程仓库</h3><pre><code>右键项目 》》 Git 》》Repository 》》Remotes. 有 + 、- 操作
</code></pre>
<h3 id="推送远程仓库"><a href="#推送远程仓库" class="headerlink" title="推送远程仓库"></a>推送远程仓库</h3><pre><code>右键项目 》》 Git 》》Repository 》》push 》》右下角commit and push提交推送
</code></pre>
<h3 id="从远程仓库拉取"><a href="#从远程仓库拉取" class="headerlink" title="从远程仓库拉取"></a>从远程仓库拉取</h3><h2 id="分支操作-1"><a href="#分支操作-1" class="headerlink" title="分支操作"></a>分支操作</h2><h3 id="查看分支"><a href="#查看分支" class="headerlink" title="查看分支"></a>查看分支</h3><pre><code>右键项目 》》 Git 》》Repository 》》Branches 或者
IDEA右下角是当前分支名称 点击
</code></pre>
<h3 id="创建分支"><a href="#创建分支" class="headerlink" title="创建分支"></a>创建分支</h3><pre><code>IDEA右下角是当前分支名称 点击 new branch
</code></pre>
<h3 id="切换分支"><a href="#切换分支" class="headerlink" title="切换分支"></a>切换分支</h3><pre><code>IDEA右下角是当前分支名称 点击 new branch 勾选 checkout branch
</code></pre>
<h3 id="将分支推送到远程仓库"><a href="#将分支推送到远程仓库" class="headerlink" title="将分支推送到远程仓库"></a>将分支推送到远程仓库</h3><pre><code>IDEA右下角是当前分支名称 点击想要推送的分支 》》 push
</code></pre>
<h3 id="合并分支"><a href="#合并分支" class="headerlink" title="合并分支"></a>合并分支</h3><pre><code>IDEA右下角是当前分支名称 点击想要合并的分支 》》 Merge into Current
</code></pre>

</article>
    
    <div class="trm-reward">
        
            <span class="trm-reward-btn trm-glow" onclick='var qr = document.getElementById("qr"); qr.style.display = (qr.style.display === "none") ? "block" : "none";'>
                <i class="iconfont fas fa-hand-holding-usd"></i>
            </span>
        
        <p class="trm-reward-comment">I'm so cute. Please give me money.</p>
        <div id="qr" style="display:none;">
            
                <div style="display:inline-block">
                    <a rel="noopener noreferrer" href='\img\QRCode.jpg' target='_blank' >
                       <img src="/myblog/%5Cimg%5CQRCode.jpg" alt="微信" loading="lazy">
                    </a>
                    <p>微信</p>
                </div>
            
                <div style="display:inline-block">
                    <a rel="noopener noreferrer" href='\img\Alipay.jpg' target='_blank' >
                       <img src="/myblog/%5Cimg%5CAlipay.jpg" alt="支付宝" loading="lazy">
                    </a>
                    <p>支付宝</p>
                </div>
            
        </div>
    </div>

    

</div>
<div id="post-next-prev" class="row">
    <div class="col-lg-12">
        <!-- title -->
        <h5 class="trm-title-with-divider">
            其他文章
            <span data-number="02"></span>
        </h5>
    </div>
    
        <div class="col-lg-6">
    <div class="trm-blog-card trm-scroll-animation" data-scroll data-scroll-offset="40">
        <a href="/myblog/2023/07/21/%E7%91%9E%E5%90%89%E5%A4%96%E5%8D%96%E4%BB%A3%E7%A0%81%E8%AF%A6%E8%A7%A3/" class="trm-cover-frame trm-anima-link">
            
            
                <img alt="cover" class="no-fancybox" src="/myblog/img/block.jpg">
            
        </a>
        
        <div class="trm-card-descr">
            <div class="trm-label trm-category trm-mb-20">
                <a href=" /myblog/categories/learn-and-imitate/">
                    learn and imitate
                </a>
            </div>
            <h5>
                <a href="/myblog/2023/07/21/%E7%91%9E%E5%90%89%E5%A4%96%E5%8D%96%E4%BB%A3%E7%A0%81%E8%AF%A6%E8%A7%A3/" class="trm-anima-link">
                    吉瑞外卖开发详解
                </a>
            </h5>
            <div class="trm-divider trm-mb-20 trm-mt-20"></div>
            <ul class="trm-card-data trm-label">
                <li>23/07/21</li>
                <li>09:10</li>
                
                
            </ul>
        </div>
    </div>
</div>
    
    
</div>

    



                    <div class="trm-divider footer-divider"></div>

                    <!-- footer -->
                    <footer class="trm-scroll-animation" data-scroll data-scroll-offset="50">

    
        <div class="trm-footer-item">
            <a rel="noopener" href="https://beian.miit.gov.cn/" target="_blank"></a>
        </div>
    

    

    
        <div class="trm-footer-item">
            <span>
                由 <a href="https://hexo.io" target="_blank" rel="noopener">Hexo</a> 驱动 v6.3.0
            </span>
            <span class="footer-separator" data-separator=" | "></span>
            <span> 
                主题 - 
                <a rel="noopener" href='https://github.com/MaLuns/hexo-theme-async' target='_blank'>Async</a>
                v2.0.9
            </span>
        </div>
      

    
        <div class="trm-footer-item">
            博客已萌萌哒运行 <span id="since" class="trm-accent-color"></span> 天
        </div>
     

    
        <div class="trm-footer-item">
            Hosted by <a href="https://github.com" rel="noopener" target="_blank">Github Pages</a>
        </div>
     
</footer>

<script>
    function show_date_time () {
        var BirthDay = new Date("07/15/2023 17:57:32");
        var today = new Date();
        var timeold = (today.getTime() - BirthDay.getTime());
        var msPerDay = 24 * 60 * 60 * 1000
        var day = Math.floor(timeold / msPerDay)
        since.innerHTML = day
    }
    show_date_time()
</script>
 
                    <!-- footer end -->

                </div>
            </div>
        </div>
    </div>
</div>
            <!-- body end -->

            <div class="trm-fixed-container" data-scroll data-scroll-sticky data-scroll-target=".locomotive-scroll__sticky-target" data-scroll-offset="-10">
    
        <div class="trm-fixed-btn" data-title="阅读模式" onclick="asyncFun.switchReadMode()">
            <i class="iconfont fas fa-book-reader"></i>
        </div>
    
    
    <div id="trm-back-top" class="trm-fixed-btn" data-title="回到顶部">
        <i class="iconfont fas fa-arrow-up"></i>
    </div>
</div>
          </div>
        </div>
      </div>
      <!-- scroll container end -->

  </div>
  <!-- app wrapper end -->

  
  <!-- Plugin -->




    
    
<script src="https://unpkg.com/locomotive-scroll@4.1.4/dist/locomotive-scroll.min.js"></script>

    
<script src="https://unpkg.com/@fancyapps/ui@4.0/dist/fancybox.umd.js"></script>

    

    
        <script src="/myblog/js/plugins/typing.js?v=2.0.9"></script>
    

    

    <!-- 数学公式 -->
    

    <!-- 评论插件 -->
    
        

        
    



<!-- CDN -->


    

    

    




    <!-- Service Worker -->
    
    <!-- baidu push -->
    


<script id="async-script" src="/myblog/js/main.js?v=2.0.9"></script>

</body>

</html>